﻿<!DOCTYPE html>
<html lang="en-us">
<head>
    <meta charset="utf-8">
    <title>编码转换规则管理</title>
    <meta name="description" content="">
    <meta name="author" content="">

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <!-- #CSS Links -->
    <!-- Basic Styles -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="css/font-awesome.css">

    <!-- SmartAdmin Styles : Caution! DO NOT change the order -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/smartadmin-production-plugins.css">
    <link rel="stylesheet" type="text/css" media="screen" href="css/smartadmin-production.css">
    <link rel="stylesheet" type="text/css" media="screen" href="css/smartadmin-skins.css">

    <!-- SmartAdmin RTL Support -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/smartadmin-rtl.css">

    <!-- Demo purpose only: goes with demo.js, you can delete this css when designing your own WebApp -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/demo.css">

    <!-- #FAVICONS -->
    <link rel="shortcut icon" href="img/favicon/favicon.ico" type="image/x-icon">
    <link rel="icon" href="img/favicon/favicon.ico" type="image/x-icon">

    <!-- #GOOGLE FONT -->
    <link rel="stylesheet" href="css/open-sans.css" type="text/css">

    <!-- #APP SCREEN / ICONS -->
    <link rel="apple-touch-icon" href="img/splash/sptouch-icon-iphone.png">
    <link rel="apple-touch-icon" sizes="76x76" href="img/splash/touch-icon-ipad.png">
    <link rel="apple-touch-icon" sizes="120x120" href="img/splash/touch-icon-iphone-retina.png">
    <link rel="apple-touch-icon" sizes="152x152" href="img/splash/touch-icon-ipad-retina.png">

    <!-- iOS web-app metas : hides Safari UI Components and Changes Status Bar Appearance -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <!-- Startup image for web apps -->
    <link rel="apple-touch-startup-image" href="img/splash/ipad-landscape.png"
        media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape)">
    <link rel="apple-touch-startup-image" href="img/splash/ipad-portrait.png"
        media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)">
    <link rel="apple-touch-startup-image" href="img/splash/iphone.png" media="screen and (max-device-width: 320px)">
    <link href="appcss/Common.css" rel="stylesheet" />


</head>
<body class="desktop-detected minified">

    <!-- #MAIN PANEL -->
    <div id="main" role="main">

        <!-- RIBBON -->
        <div id="ribbon">

            <span class="ribbon-button-alignment">
                <span class="btn btn-ribbon"><i class="fa fa-home"></i></span>
            </span>

            <!-- breadcrumb -->
            <ol class="breadcrumb">
                <li><a href="CodeConversionRuleManagementOne.html">编码转换规则管理-选择数据表</a></li>
                <li>编码转换规则管理</li>
            </ol>
            <!-- end breadcrumb -->

        </div>
        <!-- END RIBBON -->


        <!-- MAIN CONTENT -->
        <div id="content">
            <div class="row hidden">
                <div class="col-xs-12 col-sm-7 col-md-7 col-lg-4">
                    <h2 class="page-title txt-color-blueDark">
                        <i class="fa fa-table fa-fw "></i>
                        主页
                        <span>编码转换规则管理
                        </span>
                    </h2>
                </div>
            </div>

            <!-- widget grid -->
            <section id="widget-grid" class="">

                <!-- row -->
                <div class="row">
                    <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <div class="jarviswidget jarviswidget-sortable" id="DataTable-Column">
                            <header>
                                <span class="widget-icon"><i class="fa fa-table"></i></span>
                                <h2>数据表字段列表</h2>
                            </header>
                            <div>
                                <div class="widget-body">
                                    <div class="table-responsive">
                                        <table class="table table-bordered table-hover smart-form" id="Table-Column">
                                            <thead>
                                                <tr>
                                                    <th>名称</th>
                                                    <th>类型</th>
                                                    <th>长度</th>
                                                    <th>为空</th>
                                                    <th>操作</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                            </tbody>
                                        </table>

                                    </div>

                                </div>
                            </div>
                        </div>
                        <!-- Widget ID (each widget will need unique ID)-->
                        <div class="jarviswidget jarviswidget-sortable" id="wid-id-0" style="display: none">
                            <header>
                                <span class="widget-icon"><i class="fa fa-table"></i></span>

                                <h2>编码转换规则列表</h2>
                            </header>

                            <!-- widget div-->
                            <div>
                                <!-- end widget edit box -->
                                <!-- widget content -->
                                <div class="widget-body">
                                    <ul class="demo-btns">
                                        <li>
                                            <a class="btn  btn-default btn-xs" href="javascript:void(0);" onclick="AddData()">新增</a>
                                        </li>
                                    </ul>
                                    <div class="table-responsive">

                                        <table class="table table-bordered  table-hover smart-form smart-form" id="datalist-table">
                                            <thead>
                                                <tr>
                                                    <th>维度名称</th>
                                                    <th>维度编码</th>
                                                    <th>维度项名称</th>
                                                    <th>维度项编码</th>
                                                    <th>RawCodes</th>
                                                    <th>操作</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <tr>

                                                    <td>Row 4</td>
                                                    <td>手动</td>
                                                    <td><a href="javascript:void(0);"><i
                                                        class="fa fa-pencil-square-o "></i>编辑</a></td>
                                                </tr>

                                            </tbody>
                                        </table>

                                    </div>

                                </div>
                                <!-- end widget content -->

                            </div>
                            <!-- end widget div -->

                        </div>

                        <!-- end widget -->

                    </article>
                    <!-- WIDGET END -->

                </div>

                <!-- end row -->

            </section>
            <!-- end widget grid -->
        </div>
        <!-- END MAIN CONTENT -->
    </div>

    <!-- END #MAIN CONTENT -->

    <!--================================================== -->

    <!-- PACE LOADER - turn this on if you want ajax loading to show (caution: uses lots of memory on iDevices)
<script data-pace-options='{ "restartOnRequestAfter": true }' src="js/plugin/pace/pace.min.js"></script>-->


    <!-- #PLUGINS -->
    <!-- Link to Google CDN's jQuery + jQueryUI; fall back to local -->


    <script src="js/libs/jquery-2.1.1.min.js"></script>
    <script src="js/libs/jquery-ui-1.10.3.min.js"></script>
    <!-- BOOTSTRAP JS -->
    <script src="js/bootstrap/bootstrap.min.js"></script>

    <!-- IMPORTANT: APP CONFIG -->
    <script src="js/app.config.js"></script>


    <!-- CUSTOM NOTIFICATION -->
    <script src="js/notification/SmartNotification.min.js"></script>

    <!-- JARVIS WIDGETS -->
    <script src="js/smartwidgets/jarvis.widget.min.js"></script>


    <!-- SPARKLINES -->
    <script src="js/plugin/sparkline/jquery.sparkline.min.js"></script>

    <!-- JQUERY MASKED INPUT -->
    <script src="js/plugin/masked-input/jquery.maskedinput.min.js"></script>


    <!-- JQUERY UI + Bootstrap Slider -->
    <script src="js/plugin/bootstrap-slider/bootstrap-slider.min.js"></script>

    <!-- JQUERY UI + Bootstrap Slider -->
    <script src="js/plugin/bootstrap-slider/bootstrap-slider.min.js"></script>
    <script src="js/plugin/datatables/jquery.dataTables.min.js"></script>
    <script src="js/plugin/datatables/dataTables.colVis.min.js"></script>
    <script src="js/plugin/datatables/dataTables.tableTools.min.js"></script>
    <script src="js/plugin/datatables/dataTables.bootstrap.min.js"></script>
    <script src="js/plugin/datatable-responsive/datatables.responsive.min.js"></script>
    <script src="appjs/Common.js"></script>
    <script src="appjs/Helper.js"></script>
    <script src="js/app.min.js"></script>
    <script>
        var draw = 0;
        var table;
        var datatableId = GetQueryString("dataTableId");
        var datacolumnId = "";
        $(function () {
            //初始化数据表对应的列
            var initializationDataTableForColumns = function () {
                $.ajax({
                    url: apiUrl,
                    data: {
                        "sys:sno": "DataTable",
                        "sys:act": "GetColumns",
                        "DataTableId": datatableId
                    },
                    dataType: "json",
                    success: function (data) {
                        if (data.IsSccuess) {
                            var trs = "";
                            for (var i = 0; i < data.Data.Columns.length; i++) {
                                trs += "<tr><td>";
                                trs += (data.Data.Columns[i].Name + "</td>");
                                trs += ("<td>" + data.Data.Columns[i].Type + "</td>");
                                trs += ("<td>" + data.Data.Columns[i].Length + "</td>");
                                trs += ("<td>" + (data.Data.Columns[i].Nullable ? "<input type='checkbox' disabled='disabled'checked='checked' />" : "<input  type='checkbox'disabled='disabled' />") + "</td>");
                                trs += ("<td>" + "<a href='javascript:void(0);' onclick=\"GetDateResult('" + data.Data.Columns[i].Id + "')\"><i class=\"fa fa-hand-o-right\"></i>查看</a>" + "</td></tr>");
                            }
                            $("#Table-Column tbody").html(trs);
                        } else {
                            if (IsLogined(data.ErrorCode)) {
                                alert("失败（" + "错误代码：" + data.ErrorCode + "，错误信息：" + data.Message + ")");
                            }
                        }

                    }
                });
            }
            initializationDataTableForColumns();
        });
        //初始化表格
        var initializationDataTableForCode = function () {
            table = $('#datalist-table').dataTable({
                "autoWidth": true,
                "oLanguage": dataTableConfig,
                ordering: false,
                bProcessing: true,
                "bLengthChange": false,
                bStateSave: true,
                serverSide: true,
                searching: false,
                aLengthMenu: [25],
                "ajax": {
                    url: apiUrl,
                    "dataSrc": function (json) {
                        if (json.IsSccuess) {
                            var newjson = new Array();
                            for (var i = 0; i < json.Data.Items.length; i++) {
                                var editstr = "";
                                editstr += ("<a href=\"CodeConversionRuleUpdate.html?Id=" + json.Data.Items[i].Id + "&dataTableId=" + datatableId + "&dataColumnId=" + datacolumnId + "\"><i class=\"fa fa-edit \"></i>编辑</a>");
                                editstr += "<a href=\"javascript:void(0);\" onclick=\"DeleteDate(this)\" data-Id=\"" + json.Data.Items[i].Id;
                                editstr += "\"><i class=\"fa  fa-times-circle\"></i>删除</a>";

                                newjson.push({ "dimname": json.Data.Items[i].DimName, "dimcode": json.Data.Items[i].DimCode, "dimitemname": json.Data.Items[i].DimItemName, "dimitemcode": json.Data.Items[i].DimItemCode, "rawcodes": json.Data.Items[i].RawCodes, "option": editstr });
                            }


                            return newjson;
                        } else {
                            if (IsLogined(json.ErrorCode)) {
                                alert("失败（" + "错误代码：" + json.ErrorCode + "，错误信息：" + json.Message + ")");
                            }
                        }
                        return [];
                    },
                    "data": function (d) {
                        draw = d.draw;
                        return $.extend({}, { "sys:sno": "ETL" }, { "sys:act": "GetCodeConversionRuleList" }, { "DataTableId": datatableId }, { "DataColumnId": datacolumnId }, { "draw": d.draw }, { "length": d.length }, { "Page": parseInt(d.start / d.length) });
                    }
                },
                columns: [
                    { data: 'dimname' },
                    { data: 'dimcode' },
                    { data: 'dimitemname' },
                    { data: 'dimitemcode' },
                    { data: 'rawcodes' },
                    { data: 'option' }
                ]
            });
        }
        var GetDateResult = function (obj) {
            datacolumnId = obj;
            $("#wid-id-0").show();
            if (draw == 0) {
                initializationDataTableForCode();
            } else {
                table.fnDraw();
            }
        }
        var DeleteDate = function (obj) {
            var $this = $(obj);
            var id = $this.attr("data-Id");
            if (confirm("确定删除该项？")) {
                $.ajax({
                    url: apiUrl,
                    data: {
                        "sys:sno": "ETL",
                        "sys:act": "DeleteCodeConversionRule",
                        "Id": id
                    },
                    type: "Post",
                    dataType: "json",
                    success: function (data) {
                        if (data.IsSccuess) {
                            if (DeleteDataThenReload) {
                                ShowGritter("删除成功", 2);
                            } else {
                                ShowGritter("删除成功");
                                $this.parent().parent().remove();
                            }
                        } else {
                            if (IsLogined(data.ErrorCode)) {
                                alert("失败（" + "错误代码：" + data.ErrorCode + "，错误信息：" + data.Message + ")");
                            }
                        }
                    },
                    beforeSend: function () {
                        ShowGritter("提交中");
                    },
                    error: function () {
                        alert("系统异常，请稍后重试");
                    }
                });
            }
        }
        //处理添加的链接
        var AddData = function () {
            var url = "CodeConversionRuleCreate.html";
            window.location.href = url + "?dataTableId=" + datatableId + "&dataColumnId=" + datacolumnId;
        }

    </script>

</body>
</html>
